/**
 * Created by gaolk
 *
 * 用于网站全局遮罩弹窗
 */
define(['jquery'],function($){
	var Alert={
		Add_html:"",//载入容器
		Wrap:function(Awidth,Atitle,Acontent,Atype){
			var _left=($(window).width()-Awidth)/2;
			switch(Atype){
				case 1:
					Alert.Add_html='<div id="pop_full_window" style="height:'+$(document).height()+'px;width:'
					+$(window).width()+'px;"></div>'+'<div id="pop_Opendiv" style="width:'+Awidth
					+'px;left:'+_left+'px;"><h3>'+Atitle+'<span id="pop_Opendiv_close">x</span></h3>'
					+'<div class="pop_Opendiv_content">'+Acontent+'</div></div>';
					break;//加载内容
				case 2:
					Alert.Add_html='<div id="pop_full_window" style="height:'+$(document).height()+'px;width:'
					+$(window).width()+'px;"></div>'+'<div id="pop_Opendiv" style="width:'+Awidth
					+'px;left:'+_left+'px;"><h3>'+Atitle+'<span id="pop_Opendiv_close">x</span></h3>'
					+'<div class="pop_Opendiv_content">'+Acontent+'</div><div class="pop_confirm_wrap">'
					+'<a href="javascript:void(0);" id="Open_confirm_no">取消</a>'
					+'<a href="javascript:void(0);" id="Open_confirm_ok">确定</a></div></div>';
					break;//模拟确定取消对话框
				case 3:
					Alert.Add_html='<div id="pop_full_window" style="height:'+$(document).height()+'px;width:'
					+$(window).width()+'px;"></div>'+'<div id="pop_Opendiv" style="width:'+Awidth
					+'px;left:'+_left+'px;"><h3>'+Atitle+'<span id="pop_Opendiv_close">x</span></h3>'
					+'<div class="pop_Opendiv_content"><div class="Open_state_success"><p><span></span>'
					+Acontent+'</p></div></div>'+'</div>';
					break;//成功提示框
				case 4:
					Alert.Add_html='<div id="pop_full_window" style="height:'+$(document).height()+'px;width:'
					+$(window).width()+'px;"></div>'+'<div id="pop_Opendiv" style="width:'+Awidth
					+'px;left:'+_left+'px;"><h3>'+Atitle+'<span id="pop_Opendiv_close">x</span></h3>'
					+'<div class="pop_Opendiv_content"><div class="Open_state_error"><p><span></span>'
					+Acontent+'</p></div></div>'+'</div>';
					break;//失败提示框
				case 5:
					Alert.Add_html='<div id="pop_full_window" style="height:'+$(document).height()+'px;width:'
					+$(window).width()+'px;"></div>'+'<div id="pop_Opendiv" style="width:'+Awidth
					+'px;left:'+_left+'px;"><h3 style="display:none"><span id="pop_Opendiv_close">x</span>'
					+'</h3><div class="pop_Opendiv_content pop_Opendiv_loading"><div class="Open_state_load">'
					+'<p><span></span>'+Acontent+'</p></div></div>'+'</div>';
					break;//加载中提示框
			}
			$('body').append(Alert.Add_html);
			$('#pop_Opendiv').css('top',$(document).scrollTop()+(($(window).height()-$('#pop_Opendiv').height())/2)+'px');
		},//载入弹窗公用HTML
		Box:function(s_width,s_title,s_content,s_time,callback){
			Alert.Wrap(s_width,s_title,s_content,1);
			var _time;
			if(s_time>0){
				_time=setTimeout(function(){$('#pop_Opendiv_close').click()},s_time);
			}
			$('#pop_Opendiv_close').click(function(){
				if( typeof callback =="function") {callback(callback);}
				$('#pop_full_window,#pop_Opendiv').remove();
				clearTimeout(_time);
			})
		},//载入内容弹窗
		Confirm:function(s_width,s_title,s_content,s_time,callback){
			Alert.Wrap(s_width,s_title,s_content,2);
			var _time;
			if(s_time>0){
				_time=setTimeout(function(){$('#pop_Opendiv_close').click()},s_time);
			}
			$('#pop_Opendiv_close,#Open_confirm_no').click(function(){
				$('#pop_full_window,#pop_Opendiv').remove();
				clearTimeout(_time);
			});
			$('#Open_confirm_ok').click(function(){
				if( typeof callback =="function"){callback(callback);
				}else{
					$('#pop_full_window,#pop_Opendiv').remove();
				}
				clearTimeout(_time);
			})
		}, //确定取消弹窗
		Message:function(s_width,s_title,s_content,s_time,s_state,callback){
			var _state=s_state;
			var _time;
			switch(s_state){
				case 0:
					Alert.Wrap(s_width,s_title,s_content,3);
					break;
				case 1:
					Alert.Wrap(s_width,s_title,s_content,4);
					break;
				case 2:
					Alert.Wrap(s_width,s_title,s_content,5);
					break;
			}// 0调成功样式 1调失败样式 2调加载中样式
			if(s_time>0){
				_time=setTimeout(function(){$('#pop_Opendiv_close').click()},s_time);
			}
			$('#pop_Opendiv_close').click(function(){
				$('#pop_full_window,#pop_Opendiv').remove();
				if( typeof callback =="function") {callback(callback);}
				clearTimeout(_time);
			})
		}//成功失败弹窗
	};
	return {
		Box:Alert.Box,
		Confirm:Alert.Confirm,
		Message:Alert.Message
	}
});